import request from '@/utils/request';
import { AxiosPromise } from 'axios';
import { RechargeRulesVO, RechargeRulesForm, RechargeRulesQuery } from '@/api/tearoom/rechargeRules/types';

/**
 * 查询充值规则列表
 * @param query
 * @returns {*}
 */

export const listRechargeRules = (query?: RechargeRulesQuery): AxiosPromise<RechargeRulesVO[]> => {
  return request({
    url: '/tearoom/rechargeRules/list',
    method: 'get',
    params: query
  });
};

/**
 * 查询充值规则详细
 * @param id
 */
export const getRechargeRules = (id: string | number): AxiosPromise<RechargeRulesVO> => {
  return request({
    url: '/tearoom/rechargeRules/' + id,
    method: 'get'
  });
};

/**
 * 新增充值规则
 * @param data
 */
export const addRechargeRules = (data: RechargeRulesForm) => {
  return request({
    url: '/tearoom/rechargeRules',
    method: 'post',
    data: data
  });
};

/**
 * 修改充值规则
 * @param data
 */
export const updateRechargeRules = (data: RechargeRulesForm) => {
  return request({
    url: '/tearoom/rechargeRules',
    method: 'put',
    data: data
  });
};

/**
 * 删除充值规则
 * @param id
 */
export const delRechargeRules = (id: string | number | Array<string | number>) => {
  return request({
    url: '/tearoom/rechargeRules/' + id,
    method: 'delete'
  });
};
